//
//  BasicTestViewController.m
//  MirkoLibTest
//
//  Created by Mirko on 2017/3/20.
//  Copyright © 2017年 Mirko. All rights reserved.
//

#import "BasicTestViewController.h"

@interface BasicTestViewController ()

@end

@implementation BasicTestViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    btn.frame = CGRectMake(0, 0, 80, 44);
    [btn setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    
    [btn addTarget:self action:@selector(goBack:)forControlEvents:UIControlEventTouchUpInside];
    
    
    
    [btn setTitle:@"back" forState:UIControlStateNormal];
    UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithCustomView:btn];
    [self.navigationItem setLeftBarButtonItem:item];
    
}

-(void) goBack:(UIButton *) btn
{
    [self.navigationController popViewControllerAnimated:YES];
}

-(void) addRightBttonAction:(SEL) seleter
{
    
    UIButton *rBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    rBtn.frame = CGRectMake(0, 0, 80, 44);
    [rBtn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    
    if (seleter) {
        [rBtn addTarget:self action:seleter forControlEvents:UIControlEventTouchUpInside];
    }
    else
    {
        [rBtn addTarget:self action:@selector(handleRightBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    }
    
    [rBtn setTitle:@"button" forState:UIControlStateNormal];
    UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithCustomView:rBtn];
    [self.navigationItem setRightBarButtonItem:item];
}

-(void) handleRightBtnAction:(UIButton*) button
{
    
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
